home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / basecvrt / basecvt1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  4.9 KB  |  179 lines

  1. VERSION 2.00
  2. Begin Form Main 
  3.    BackColor       =   &H00E0E0E0&
  4.    Caption         =   "BaseConvert"
  5.    ClientHeight    =   3030
  6.    ClientLeft      =   2925
  7.    ClientTop       =   1800
  8.    ClientWidth     =   3075
  9.    Height          =   3720
  10.    Icon            =   BASECVT1.FRX:0000
  11.    Left            =   2865
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   3030
  16.    ScaleWidth      =   3075
  17.    Top             =   1170
  18.    Width           =   3195
  19.    Begin TextBox UserInput 
  20.       Height          =   375
  21.       Left            =   960
  22.       TabIndex        =   1
  23.       Top             =   1800
  24.       Width           =   1215
  25.    End
  26.    Begin CommandButton Command1 
  27.       Caption         =   "Another"
  28.       Height          =   615
  29.       Left            =   240
  30.       TabIndex        =   7
  31.       Top             =   720
  32.       Width           =   1215
  33.    End
  34.    Begin ComboBox BaseList 
  35.       Height          =   300
  36.       Left            =   1920
  37.       Style           =   2  'Dropdown List
  38.       TabIndex        =   0
  39.       Top             =   480
  40.       Width           =   975
  41.    End
  42.    Begin CommandButton ConvertCmd 
  43.       Caption         =   "Convert"
  44.       Default         =   -1  'True
  45.       Height          =   615
  46.       Left            =   240
  47.       TabIndex        =   6
  48.       Top             =   120
  49.       Width           =   1215
  50.    End
  51.    Begin Label Answer 
  52.       Alignment       =   2  'Center
  53.       BorderStyle     =   1  'Fixed Single
  54.       ForeColor       =   &H000000FF&
  55.       Height          =   345
  56.       Left            =   240
  57.       TabIndex        =   4
  58.       Top             =   2520
  59.       Width           =   2625
  60.    End
  61.    Begin Label Label2 
  62.       BackColor       =   &H00FFFFFF&
  63.       BorderStyle     =   1  'Fixed Single
  64.       Caption         =   "New Number"
  65.       Height          =   255
  66.       Left            =   960
  67.       TabIndex        =   3
  68.       Top             =   2280
  69.       Width           =   1215
  70.    End
  71.    Begin Label Label1 
  72.       BorderStyle     =   1  'Fixed Single
  73.       Caption         =   "Your Number"
  74.       Height          =   255
  75.       Left            =   960
  76.       TabIndex        =   2
  77.       Top             =   1560
  78.       Width           =   1215
  79.    End
  80.    Begin Label Label3 
  81.       BorderStyle     =   1  'Fixed Single
  82.       Caption         =   "New Base"
  83.       Height          =   255
  84.       Left            =   1920
  85.       TabIndex        =   5
  86.       Top             =   240
  87.       Width           =   975
  88.    End
  89.    Begin Menu Filemenu 
  90.       Caption         =   "File"
  91.       Begin Menu AboutMenu 
  92.          Caption         =   "About"
  93.       End
  94.       Begin Menu HelpMenu 
  95.          Caption         =   "Help"
  96.       End
  97.       Begin Menu separator 
  98.          Caption         =   "-"
  99.       End
  100.       Begin Menu ExitMenu 
  101.          Caption         =   "Exit"
  102.       End
  103.    End
  104. Sub AboutMenu_Click ()
  105.     aboutform.Show
  106. End Sub
  107. Sub BaseList_Click ()
  108.  userinput.SetFocus
  109. End Sub
  110. Sub BaseList_GotFocus ()
  111.     Static flag%
  112.     If flag% = 0 Then
  113.         baselist.AddItem Str$(2)
  114.         baselist.AddItem Str$(3)
  115.         baselist.AddItem Str$(4)
  116.         baselist.AddItem Str$(5)
  117.         baselist.AddItem Str$(6)
  118.         baselist.AddItem Str$(7)
  119.         baselist.AddItem Str$(8)
  120.         baselist.AddItem Str$(9)
  121.         baselist.AddItem Str$(16)
  122.     End If
  123.     flag% = 1
  124. End Sub
  125. Sub Command1_Click ()
  126.     userinput.text = ""
  127.     answer.caption = ""
  128.     userinput.SetFocus
  129. End Sub
  130. Sub convertcmd_click ()
  131.     userinput.SetFocus
  132.     Static n&, b%, R&, I%, Q&, C%, Limit%
  133.     I% = 1 'array digitcounter
  134.     Limit% = 100' array size
  135.     ReDim RR(1 To Limit%) As Integer
  136.     n& = Val(userinput.text)
  137.     b% = Val(baselist.text)
  138.     ans$ = ""
  139.     If b% <> 16 Then
  140.         While (n& <> 0) 'start base conversion
  141.             R& = n& Mod b%
  142.             RR(I%) = R&
  143.             I% = I% + 1
  144.             Q& = n& \ b%
  145.             n& = Q&
  146.         Wend
  147.         I% = I% - 1'set counter to correct number
  148.         For C% = 1 To I% 'read array
  149.             ans$ = LTrim$(Str$(RR(C%)) + ans$)
  150.         Next
  151.         answer.caption = ans$
  152.     Else
  153.         answer.caption = Hex$(n&)
  154.     End If
  155. End Sub
  156. Sub ExitMenu_Click ()
  157.       End
  158. End Sub
  159. Sub HelpMenu_Click ()
  160.     help.Show
  161. End Sub
  162. Sub UserInput_Change ()
  163.     msg$ = "Your number is restricted" + Chr$(13) + Chr$(10) + "to a maximum of 8 digits."
  164.     title$ = "Entry Error"
  165.     If Len(userinput.text) > 8 Then
  166.         MsgBox msg$, 64, title$
  167.         userinput.text = ""
  168.     End If
  169. End Sub
  170. Sub UserInput_KeyPress (keyascii As Integer)
  171.     A% = keyascii
  172.  If A% < 47 Or A% > 58 Then ' integers 0 thru 9
  173.         keyascii = 0
  174.         msg$ = "Enter Postive Numbers Only"
  175.         title$ = "Entry Error"
  176.         MsgBox (msg$), 48, title$
  177.     End If
  178. End Sub
  179.